package projectEuler.net;

public class Problem_044 {
	private static boolean isPentagonal(int Pn){
		double test = (Math.sqrt(24 * Pn + 1) + 1) / 6;
		return (test ==(int)test);
	}
	private static int buildPentagonal(int n){
		if(n<1) return 0;
//		System.out.printf("__%d\n", n*(3*n-1)/2);
		return n*(3*n-1)/2;
	}
	public static int findMinDiffOfTwoSpecificPantagonal(){
		int pentagonal, pentagonalN;
		for(int i =2;;i++){
			pentagonal = buildPentagonal(i);
			for(int j= i-1; j>=1; j--){
				pentagonalN = buildPentagonal(j);
			
				if(isPentagonal(pentagonal-pentagonalN)&&(isPentagonal(pentagonal+pentagonalN))){
					return pentagonal-pentagonalN;
				}
			}
		}
//		return 0;
	}
}
